package com.example.fence.entity;

import com.example.fence.vo.FenceVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.LinkedList;
import java.util.List;

/**
 * 电子围栏类，保存电子围栏的信息
 */
@Data
@Component
@NoArgsConstructor
@AllArgsConstructor
public class Fence {
    private List<String> pointList;
    private List<String> devices;

    public Fence(FenceVo fenceVo){

        this.pointList=new LinkedList<>();
        // List<List<Double>> path转换为List<String> pointList
        for(List<Double> point:fenceVo.getPath()){
            String pointStr=point.get(0).toString()+","+point.get(1).toString();
            this.pointList.add(pointStr);
        }

        this.devices=fenceVo.getDevices();

    }
}
